package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo12MapValues {
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setMaster("local")
      .setAppName("map")


    val sc = new SparkContext(conf)


    val ageRDD: RDD[(String, Int)] = sc.parallelize(List(("001", 23), ("002", 24), ("003", 25)))

    /**
      *
      * mapValues:处理kv格式的rdd,  处理value key 不变
      */

    val rdd1: RDD[(String, Int)] = ageRDD.mapValues(value => value + 1)


    rdd1.foreach(println)

  }

}
